﻿@model OrderMasterModel

@{
    Layout = "~/Views/Shared/_ContentLayout.cshtml";
}
@{
    var viewModel = Model ?? new OrderMasterModel();

}
<style>
    .table-bordered {
        border-color: #000000;
    }

        .table-bordered th, .table-bordered td {
            border-left-color: #000000;
        }

    .table th, .table td {
        border-top-color: #000000;
    }
</style>
<div style="margin:0 auto">

    @{
        var sulist = new List<long>();
        foreach (var item in viewModel.orderGoods)
        {
            if (!sulist.Contains(item.views_Goods.supplier_id.Value))
            {
                sulist.Add(item.views_Goods.supplier_id.Value);
            }
        }
        ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
        foreach (var supplier_id in sulist)
        {
            <table class="definewidth m10">
                <tr>
                    <td colspan="2" style="width:100%;font-size:24px;line-height:35px;font-weight:bold;text-align:center;">
                        采购单
                    </td>
                </tr>
            </table>
            <table class="definewidth m10">
                <tr>
                    <td>
                        @{
                            var sup_info = dbcontext.ADZ_SupplierMaster.FirstOrDefault(t => t.supplier_id == supplier_id);
                            <div>
                                供应商：@sup_info.supplier_name<br />
                                地址：@sup_info.supplier_address<br />
                                联系人：@sup_info.contact_name<br />
                                TEL：@sup_info.telephone<br />
                            </div>
                        }

                    </td>
                    <td style="width:50%;font-size:14px;">
                        送货地址：@viewModel.aDZ_OrderAddress.address_desc<br />
                        联系人：@viewModel.view_Order.receiver<br />
                        TEL：@viewModel.aDZ_OrderAddress.receiver_telephone<br />
                    </td>
                </tr>
            </table>
            <table class="definewidth m10">
                <tr>
                    <td style="width:100%;font-size:18px;line-height:24px;font-weight:bold;">订单编号：@viewModel.view_Order.order_NO 订单日期：@viewModel.view_Order.create_time.Value.ToString("yyyy年MM月dd日") </td>
                </tr>
            </table>
            <table class="table table-bordered definewidth m10">
                <tr>
                    <th>型号</th>
                    <th>品牌</th>
                    <th>批次号</th>
                    <th>数量</th>
                    <th>单价</th>
                </tr>
                @{
                    var heji = 0m;
                    foreach (var item in viewModel.orderGoods.Where(t => t.views_Goods.supplier_id == supplier_id).ToList())
                    {
                        heji += item.views_Goods.supply_price ?? 0m;
                        <tr>
                            <td>@item.views_Goods.MPN</td>
                            <td>@item.views_Goods.brand_name</td>
                            <td>@item.views_Goods.DCN</td>
                            <td>@item.aDZ_OrderDetails.amount @item.views_Goods.goods_unit</td>
                            <td>@item.views_Goods.supply_price</td>
                        </tr>
                    }
                }
                <tr>
                    <td colspan="6" style="text-align:center;">
                        @("合计(RMB)：￥" + heji + "元")
                    </td>
                </tr>
            </table>
            <div class=" definewidth m10"  style="font-size:16px;line-height:26px">
                备注：<br />
                要求所售货物为原装正品<br />
                以上价格为@((viewModel.orderGoods[0].views_Goods.include_tax == 0) ? "未税价" : "含税价")
            </div>
            <div class="m10 ">
                <table class=" definewidth m10" style="font-size:16px;line-height:36px">
                    <tr style="height:200px">
                        <td width="50%">
                            @sup_info.supplier_name<br /><br />
                            负责人签署：
                        </td>
                        <td width="50%">
                            苏州易易通电子商务有限公司<br /><br />
                            负责人签署：王淑华
                        </td>
                    </tr>
                    <tr >
                        <td width="50%"></td>
                        <td>
                            <div style="margin-top:-150px;margin-left:80px; z-index:100;position:relative;">
                                <img src="~/Images/z1.png" width="209" />
                            </div>
                        </td>
                    </tr>
                </table>
            </div>

            <div style="page-break-after:always;"></div>
        }
    }
</div>
